exports.title = '查找特定品牌型号设备的特定属性编码';
exports.path = '/wzkc/terminal/getTypeParam';
exports.pool = 'task';

exports.sqltext = `
select a.vresult
from uop_cen1.td_s_cparam a
where a.key = :key
  and a.value1 = :TERMINAL_MODEL_CODE
  and a.value2 = :BRAND_CODE
`;


// 请求范例，用于调用者了解请求数据结构，也用于系统自动内测发起请求
exports.request = {
  key: 'SUPPORT4kType',
  TERMINAL_MODEL_CODE: '103218',
  BRAND_CODE: '28001440',
};

/*
SYSTEMType 1 Linux 0 安卓 ''
SUPPORT4kType 1 4K 0否 ''
KILOMEGA_FLAG 1 千兆 0 否 ''
OnuTypeNew  ONU类型目前有三种：0 SFU; 1 有线型HGU; 2 WIFI型HGU
*/

exports.outConverter = (sqlresult, req) => {
  const data = sqlresult.rows[0];
  if (!data) {
    return {
      VRESULT: '',
    };
  }
  const vresult = +data.VRESULT; // 转成数字方便用作数组下标
  switch (req.key) {
    case 'SYSTEMType':
      return {
        ...data,
        value: ['安卓', 'Linux'][vresult],
      };
    case 'SUPPORT4kType':
      return {
        ...data,
        value: ['非4k', '4k'][vresult],
      };
    case 'KILOMEGA_FLAG':
      return {
        ...data,
        value: ['非千兆', '千兆'][vresult],
      };
    case 'OnuTypeNew':
      return {
        ...data,
        value: ['SFU', '有线型HGU', 'WIFI型HGU'][vresult],
      };
    default:
      return { ...data, key: req.key || 'nokey' };
  }
};
